﻿using Epic.Net.Utility;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Epic.Net.Extensions
{
    public static class ArrayExtensions
    {

        public static bool Join<T>(ref T[] value, T[] array)
        {
            try
            {
                int base_size = value.Length;
                int size_T = System.Runtime.InteropServices.Marshal.SizeOf(value[0]);
                Array.Resize(ref value, base_size + array.Length);
                Buffer.BlockCopy(array, 0, value, base_size * size_T, array.Length * size_T);
            }
            catch (IndexOutOfRangeException)
            {
                return false;
            }
            return true;
        }

        public static void For<T>(T[] collection, Action<T, int> action, int skip = 0)
        {
            ForUtility.For<T>(collection, action, skip);
        }

        public static void For<T>(T[] collection, Action<T[], int> action, int skip = 0, int step = 1)
        {
            ForUtility.For<T>(collection, action, skip, step);
        }

        public static void Step<T>(this T[] collection, Action<T, T> action, int skip = 0)
        {
            ForUtility.Step<T>(collection, action, skip);
        }

        public static void Step<T>(this T[] collection, Action<T, T, T> action, int skip = 0)
        {
            ForUtility.Step<T>(collection, action, skip);
        }

        public static void Step<T>(this T[] collection, Action<T, T, T, T> action, int skip = 0)
        {
            ForUtility.Step<T>(collection, action, skip);
        }

        public static void Step<T>(this T[] collection, Action<T, T, T, T, T> action, int skip = 0)
        {
            ForUtility.Step<T>(collection, action, skip);
        }

        public static void Step<T>(this T[] collection, Action<T, T, T, T, T, T> action, int skip = 0)
        {
            ForUtility.Step<T>(collection, action, skip);
        }

        public static void Step<T>(this T[] collection, Action<T, T, T, T, T, T, T> action, int skip = 0)
        {
            ForUtility.Step<T>(collection, action, skip);
        }

        public static void Step<T>(this T[] collection, Action<T, T, T, T, T, T, T, T> action, int skip = 0)
        {
            ForUtility.Step<T>(collection, action, skip);
        }

        public static void Step<T>(this T[] collection, Action<T, T, T, T, T, T, T, T, T> action, int skip = 0)
        {
            ForUtility.Step<T>(collection, action, skip);
        }
    }
}
